package com.hzvictory.hotel_system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
//import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.hzvictory.hotel_system.common.annotation.Log;
import com.hzvictory.hotel_system.common.core.controller.BaseController;
import com.hzvictory.hotel_system.common.core.domain.AjaxResult;
import com.hzvictory.hotel_system.common.enums.BusinessType;
import com.hzvictory.hotel_system.pojo.entity.Room;
import com.hzvictory.hotel_system.service.IRoomService;
//import com.hzvictory.hotel_system.common.utils.ExcelUtil;
import com.hzvictory.hotel_system.common.core.page.TableDataInfo;
/**
 * 功能
 * 作者：何征
 * 日期：2025/7/23 16:51
 */
@RestController
@RequestMapping("/system/room")
public class RoomController extends BaseController
{
    @Autowired
    private IRoomService roomService;

    /**
     * 查询房间表列表
     */
   // @PreAuthorize("@ss.hasPermi('hzvictory.hotel_system:room:list')")
    @GetMapping("/list")
    public TableDataInfo list(Room room)
    {
        startPage();
        List<Room> list = roomService.selectRoomList(room);
        return getDataTable(list);
    }

    /**
     * 导出房间表列表
     */
   // @PreAuthorize("@ss.hasPermi('hzvictory.hotel_system:room:export')")
//    @Log(title = "房间表", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, Room room)
//    {
//        List<Room> list = roomService.selectRoomList(room);
//        ExcelUtil<Room> util = new ExcelUtil<Room>(Room.class);
//        util.exportExcel(response, list, "房间表数据");
//    }

    /**
     * 获取房间表详细信息
     */
    //@PreAuthorize("@ss.hasPermi('hzvictory.hotel_system:room:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(roomService.selectRoomById(id));
    }

    /**
     * 新增房间表
     */
    //@PreAuthorize("@ss.hasPermi('hzvictory.hotel_system:room:add')")
    @Log(title = "房间表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Room room)
    {
        return toAjax(roomService.insertRoom(room));
    }

    /**
     * 修改房间表
     */
    //@PreAuthorize("@ss.hasPermi('hzvictory.hotel_system:room:edit')")
    @Log(title = "房间表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Room room)
    {
        return toAjax(roomService.updateRoom(room));
    }

    /**
     * 修改房间状态：空闲1-》0 已预订
     */
    //@PreAuthorize("@ss.hasPermi('hzvictory.hotel_system:room:edit')")
    @PutMapping("/status")
    public AjaxResult editStatus(@RequestParam Long id)
    {
        return toAjax(roomService.updateStatus(id));
    }

    /**
     * 删除房间表
     */
    //@PreAuthorize("@ss.hasPermi('hzvictory.hotel_system:room:remove')")
    @Log(title = "房间表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(roomService.deleteRoomByIds(ids));
    }
}
